package com.nlgc365.designpattern.Chapter04_Pattern.Creation.P02_Factory.Calculator;

import java.util.Scanner;

/**
 * Calculator Console Program
 * Enter two numbers and operation symbols,then get the result.
 */
public class Calculator_v1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (true) {
            // input two number
            System.out.println("Input num1: ");
            int num1 = scanner.nextInt();
            System.out.println("Input num2: ");
            int num2 = scanner.nextInt();

            // input symbol
            System.out.println("Input Symbol: ");
            String symbol = scanner.next();

            // Perform calculations and output the result in console
            switch (symbol) {
                case "+":
                    System.out.println(num1 + num2);
                    break;
                case "-":
                    System.out.println(num1 - num2);
                    break;
                case "*":
                    System.out.println(num1 * num2);
                    break;
                case "/":
                    System.out.println(num1 / num2);
                    break;
                case "%":
                    System.out.println(num1 % num2);
                    break;
                default:
                    System.out.println("Feature not supported");
                    break;
            }
        }
    }
}
